package org.demo.patten.interpreter;

/**
 * @author zhuj
 * @date 2025/3/29
 * @apiNote
 */
public class InterpreterTest {
    public static void main(String[] args) {
        // 表达式：5 + 3 - 2
        Expression e1 = new NumberExpression(5);
        Expression e2 = new NumberExpression(3);
        Expression e3 = new NumberExpression(2);
        Expression add = new AddExpression(e1, e2);      // 5 + 3
        Expression result = new SubtractExpression(add, e3); // (5 + 3) - 2
        System.out.println("结果是：" + result.interpret()); // 输出：6
    }
}
